package com.w7vm.menuweb.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.w7vm.menuweb.entity.AcessoWeb;
import com.w7vm.menuweb.entity.ContratoRestaurantesWeb;
import com.w7vm.menuweb.utility.ConstantesEJB;


@Stateless
public class ContratoRestaurantesDAO extends GenericDAO<ContratoRestaurantesWeb> {
	
	ConstantesEJB constEJB = new ConstantesEJB();
	
	@PersistenceContext
	private EntityManager em;
	
	public ContratoRestaurantesDAO() {
		super(ContratoRestaurantesWeb.class);
		// TODO Auto-generated constructor stub
	}
	
//	public int deleteContratoRestaurantes1(int idContrato){
//		System.out.println("[IAM-EJB][deleteContratoRestaurantes] :"+ idContrato);
//		try{
//			Map<String, Object> parameters = new HashMap<String, Object>();
//			parameters.put("id", idContrato);   
//			super.delete(ContratoRestaurantesWeb.DELETE_RESTAURANTESCONTRATO_BY_ID, parameters);
//			return 1;
//		}
//		catch (Exception e) {
//			return -1;
//		}
//	}
		

	
	public int deleteContratoRestaurantes(List<Integer> contratoRestaurante){
		System.out.println("[IAM-EJB][deleteContratoRestaurantes] :");

		int removed = -1;

		try{
			removed = em.createQuery("DELETE ContratoRestaurantesWeb cr WHERE cr.idContratoRestauranteWeb IN (:id)")
					.setParameter("id",contratoRestaurante)
					.executeUpdate();
		} catch (Exception e) {
				System.err.println(e.getMessage());
		}
		return removed;
	}

}
